package com.zhixing.order.websocket;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zhixing.order.domain.vo.OrderStatusVO;
import jakarta.websocket.Encoder;

public class OrderWebSocketEncoder implements Encoder.Text<OrderStatusVO> {

    private static final ObjectMapper objectMapper = new ObjectMapper();

    @Override
    public String encode(OrderStatusVO orderStatusVO) {
        try {
            return objectMapper.writeValueAsString(orderStatusVO);
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
    }
}
